package com.example.smartcity_ikun3.ui.home.adapter

import android.content.Intent
import android.text.Layout
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.smartcity_ikun3.R
import com.example.smartcity_ikun3.logic.util.Util.show
import com.example.smartcity_ikun3.ui.home.activity.WeatherActivity
import com.example.smartcity_ikun3.ui.home.model.WeatherEntity

class ReAdapterWeather (
    private val data: List<WeatherEntity>
) : RecyclerView.Adapter<ReAdapterWeather.ViewHolder>(){
    inner class ViewHolder(v: View) : RecyclerView.ViewHolder(v){
        val setImageView: ImageView = v.findViewById(R.id.weatherImageView)
        val setTitle: TextView = v.findViewById(R.id.weatherTitle)
        val setWenDu: TextView = v.findViewById(R.id.weatherWendu)
        val setKonQi: TextView = v.findViewById(R.id.weatherKonQi)
        val setShiDu: TextView = v.findViewById(R.id.weatherShidu)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val root = LayoutInflater.from(parent.context).inflate(R.layout.re_item_weather, parent, false)
        val view = ViewHolder(root)

        return view
    }

    override fun getItemCount(): Int = data.size

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val list = data[position]
        holder.setImageView.setImageResource(list.ImageView)
        holder.setTitle.text = list.title
        holder.setWenDu.text = list.WenDu
        holder.setKonQi.text = list.KonQiZhiLian
        holder.setShiDu.text = list.ShiDu
    }
}